const CryptoJs = require('crypto-js')

// Traceid值
function Traceid() {
    var e = function () {
        for (var e = Date.now().toString(16), t = "", n = 0; n < 10; n++)
            t += "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62 * Math.random())];
        return "".concat(e.slice(-6)).concat(t)
    }();
    return "F-".concat(e)
}


// kiv值
function bbbb(e) {
    void 0 === e && (e = 16);
    for (var t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""), n = "", r = 0; r < e; r++) {
        n += t[Math.ceil(61 * Math.random())]
    }
    return n
}


var s, u = (s = null,
        function () {
            return s || (s = function () {
                var e, t, n, r, i = null;
                return i || (t = new RegExp("\\u200c", "g"),
                    n = new RegExp("\\u200d", "g"),
                    r = new RegExp(".{8}", "g"),
                    e = "‍‌‍‍‍‌‌‌‍‍‌‍‍‌‍‍‍‍‌‍‍‌‍‍‍‌‍‌‍‍‍‌‍‌‌‍‍‍‍‌‍‌‌‌‍‌‌‌‍‌‌‍‍‍‌‌‍‌‌‍‌‍‌‌‍‌‍‍‍‌‌‌‍‌‌‍‍‌‌‍‍‌‌‍‍‍‍‌‍‌‍‍‌‌‍‍‍‌‍‍‍‍‌‍‍‍‌‌‌‍‍‌‍‍‌‌‍‌‌‌‍‌‌‌‍‍‌‍".replace(r, (function (e) {
                            return String.fromCharCode(parseInt(e.replace(t, 1).replace(n, 0), 2))
                        }
                    )),
                    i = {
                        key: CryptoJs.enc.Utf8.parse(e),
                        mode: CryptoJs.mode.CBC,
                        pad: CryptoJs.pad.Pkcs7
                    }),
                    i
            }()),
                s
        }
)

// var e = '{"query":"方正证券","pageNum":1,"limit":15}'
// var iv = bbbb()

// b值
function getData(e, t) {
    void 0 === e && (e = ""),
    void 0 === t && (t = "");
    var n = u()
        , r = CryptoJs.AES.encrypt(e.toString(), n.key, {
        iv: CryptoJs.enc.Utf8.parse(t),
        mode: n.mode,
        padding: n.pad
    });
    return r = r.toString()
}
// console.log(getData(e,iv))